#!/bin/sh

#set-passwd {密码} {节点IP}:{节点PORT} {节点IP}:{节点PORT} ...

passwd=$1

echo "passwd:${passwd}"

for ipAndPort in ${@:2}; do 
	echo "host:${ipAndPort}"
	array=(${ipAndPort//:/ })

	./redis-cli -c -h ${array[0]} -p ${array[1]} -a ${passwd} CONFIG SET masterauth ${passwd}
	./redis-cli -c -h ${array[0]} -p ${array[1]} -a ${passwd} CONFIG SET requirepass ${passwd}
	./redis-cli -c -h ${array[0]} -p ${array[1]} -a ${passwd} CONFIG REWRITE

done